<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库：https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库：https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------

namespace app\index\controller;

use think\admin\Controller;


/**
 * Class Gasent
 * @package app\index\controller
 */
class Gasent extends BaseController
{

    static public $limit = 6;
    public $current_nav = "gasent";
    public $table = "CmsGasEnt";

    public function index()
    {
        $this->title = "燃气企业";

        $this->page = $this->request->get("page",1);
        $offset = ($this->page-1)*self::$limit;

        $this->kw = $this->intro = $this->request->get("kw");
        $query = $this->app->db->name($this->table)->where(array("is_deleted"=>"0"));
        if($this->kw) $query = $query->whereLike("name|intro","%".$this->kw."%");
        $total = $query->count();
        $list = $query->order("id desc")->limit($offset,self::$limit)->select();

        $pager = $this->_format_page_info($total, self::$limit);
        $this->product = array(
            "list" => $list,
            "pager" => $pager,
            "kw" => $this->request->get("kw")
        );

        $this->_get_nav_menus();
        $this->_system();
        $this->fetch();
    }

    public function detail()
    {
        $id = $this->request->get("id");
        $this->article = $this->_get_article($id);
        $this->category = $this->_get_category($this->article['category_id']);
        $this->_get_nav_menus();
        $this->_system();

        if($this->category['is_private']==1 && session('member')==null){
            $this->fetch("common/accessDenied");
        }else{
            $this->_inc_read_num($id);
            $this->title = $this->article['title'];
            $this->fetch("common/detail");
        }
    }

}